<template>
	<view class="uni-padding-wrap">
		<view class="content">
			<view class="uni-form-item uni-row">
				<view class="title">新密码</view>
				<input class="uni-input" focus placeholder="请输入新密码" @input="inputNewPwd"/>
			</view>
			<view class="uni-form-item uni-row phone">
				<view class="title">确认密码</view>
				<input class="uni-input" focus placeholder="请再次确认密码" @input="checkNewPwd"/>
			</view>
			<view class="uni-form-regbtn">
				<button type="primary" class="register-btn" @click="resetPwd()">重置</button>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				array: ['中国', '美国', '巴西', '日本'],
				index: 1,
				newPwd: '',
				checknumber: ''
			}
		},
		methods: {
			bindPickerChange: function(e) {
				this.index = e.detail.value
			},
			inputNewPwd(e){
				this.newPwd = e.detail.value
				console.log(this.newPwd)
			},
			checkNewPwd(e){
				this.checknumber = e.detail.value
				console.log(this.checknumber)
			},
			resetPwd(){
				// 做逻辑判断
				if(this.newPwd === '' || this.checknumber === '') {
					alert("密码不能为空")
				} else {
					if(this.newPwd === this.checknumber) {
						uni.navigateTo({
							url: '../../pages/login/login/login',
							success: res => {
								alert("恭喜您，密码重置成功！")
							},
							fail: () => {},
							complete: () => {}
						});
					}
				}
			}
		},
		onShow() {
			// uni.setNavigationBarTitle({
			// 	title: "密码重置"
			// })
			uni.setNavigationBarColor({
				backgroundColor: "#ff2ba3",
				frontColor: "#ffffff"
			})
		}
	}
</script>

<style lang="scss">
	.content {
		border: 1px solid #d9d9d9;
		border-radius: 20upx;
		padding-top: 100upx;
		padding: 30upx 30upx 30upx 30upx;
	}
	.uni-form-item {
		border-bottom: 1px solid #D9D9D9;
	}
	.uni-row {
		input {
			text-align: left;
		}
		.title {
			line-height: 60upx;
			text-align: left;
			width: 160upx;
		}
		.href {
			color: green;
			line-height: 80upx;
			text-decoration: none;
			margin-right: 20upx;
		}
		.href:active {
			color: #aaaaff;
		}
	}
	.uni-form-regbtn {
		width: 612upx;
		margin: 0 auto;
		margin-top: 64upx;
	}
</style>